<?php

class file extends Model
{

	function getPhoto($id)
	{
		$gphoto = $this->db->getAll("SELECT file.file File,
				file.description,
				file.date,
				organization.name Org
			FROM file,organization 
			WHERE file.org_id = organization.org_id 
			AND file.org_id = ?
			ORDER BY file.date DESC",
			array($id)	
		);
		return $gphoto;
	}

	function insertPhoto( $org_id, $file, $desc, $date )
	{
		$iphoto = $this->db->execute("INSERT INTO file( org_id,
			file,
			description,
			date )
			VALUES ( ?, ?, ?, ?)", 
			array( $org_id, $file, $desc, $date )
		);
		return $iphoto;
	}

	function updatePhoto( $org_id, $file, $desc, $date, $file_id ) 
	{
		$uphoto = $this->db->execute("UPDATE file
			SET org_id = ?,
				file = ?,
				description = ?,
				date = ?
			WHERE file_id = ?",
			array( $org_id, $file, $desc, $date, $file_id )
		);
		return $uphoto;
	}

	function deletePhoto ( $file_id)
	{
		$dphoto = $this->db->execute("DELETE FROM file
			WHERE file_id = ? ",
			array( $file_id )
		);
	}

}
